/***********************************************************************
 * Module:  Npc.java
 * Author:  luohaoyang
 * Purpose: Defines the Class NPC
 ***********************************************************************/

package com.afteryuan.engine.model;
                
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;

import com.afteryuan.dao.BaseObject;

@Entity
@Table(name = "T_SCENECOMPONENTRELATION")
public class SceneComponentRelation extends BaseObject {
	public static final Integer NOT_LOAD_COMPOMENT_FUNCTIONITEM=15;
    public static final Integer NOT_LOAD_COMPOMENT_BORN=14;

    public static final Integer[] NOT_LOAD_COMPOMENTS = {
            NOT_LOAD_COMPOMENT_FUNCTIONITEM,
            NOT_LOAD_COMPOMENT_BORN,
    };



    public static final Integer TOP_NOBLOCK_LAYER = 1;//最上一层的不带BLOCK区的组件层
	public static final Integer COMPONENT_LAYER = 2;//中间带BLOCK区的组件层
	public static final Integer BUTTOM_NOBLOCK_LAYER = 3;//最下一层的不带BLOCK区的组件层
	
    private String id;
    private String name;
    private Integer x;//组件在场景中的垂直坐标X
    private Integer y;//组件在场景中的垂直坐标Y
    private Integer depth;//组件深度
    private Integer layer;//组件所在层次
    private Long createTime;
    private Long updateTime;
    private String xmlData;
    private Scene scene;//关联SCENE
    private Component component;//关联COMPONENT
    private Integer topX;//待定组件BLOCK区域的顶点格在场景斜坐标系中的坐标
    private Integer topY;

    public Integer getTopX() {
		return topX;
	}
	public void setTopX(Integer topX) {
		this.topX = topX;
	}
	public Integer getTopY() {
		return topY;
	}
	public void setTopY(Integer topY) {
		this.topY = topY;
	}
	public SceneComponentRelation(String id) {
        this.id = id;
        setCreateTime(new Date().getTime());
    }
    public SceneComponentRelation() {
        setCreateTime(new Date().getTime());
    }

    @Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getX() {
        return x;
    }

    public void setX(Integer x) {
        this.x = x;
    }

    public Integer getY() {
        return y;
    }

    public void setY(Integer y) {
        this.y = y;
    }


    public String getXmlData() {
        return xmlData;
    }

    public void setXmlData(String xmlData) {
        this.xmlData = xmlData;
    }

    @ManyToOne
    @JoinColumn(name="scene_id")
    public Scene getScene() {
        return scene;
    }

    public void setScene(Scene scene) {
        this.scene = scene;
    }

    @ManyToOne
    @JoinColumn(name="component_id")
    public Component getComponent() {
        return component;
    }

    public void setComponent(Component component) {
        this.component = component;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Long createTime) {
        this.createTime = createTime;
    }

    public Long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Long updateTime) {
        this.updateTime = updateTime;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SceneComponentRelation that = (SceneComponentRelation) o;
        if (id != null ? !id.equals(that.id) : that.id != null) return false;

        return true;
    }

    public int hashCode() {
        return (id != null ? id.hashCode() : 0);
    }

    public String toString() {
        return "SceneComponentRelation{" +
                ", id='" + id + '\'' +
                '}';
    }
	public Integer getDepth() {
		return depth;
	}
	public void setDepth(Integer depth) {
		this.depth = depth;
	}
	public Integer getLayer() {
		return layer;
	}
	public void setLayer(Integer layer) {
		this.layer = layer;
	}
}